<template>
    <view class="pub_page pub_mine_log pub_header_padding">
        <pub-head headerName="mine_log" :headerConfig="headerConfig"></pub-head>
        <div class="pub_page_scroll page_box">
            <z-paging ref="Zpaging" class="lis_div" v-model="list" @query="getList" :refresher-enabled="false"
                :fixed="false">
                <div class="lis">
                    <div class="li" v-for="(li, key) in list" :key="key">
                        <div class="txt">{{ li.remark }}</div>
                        <div class="time">{{ li.createTime }}</div>
                        <div class="num" :class="li.type == 1 ? 'num_add' : ''">{{ li.type == 1 ? '+' : '-' }}{{ li.num
                            }}
                        </div>
                    </div>
                </div>
            </z-paging>
        </div>
    </view>
</template>

<script>
export default {
    data() {
        return {
            pagescrollTop: 0,
            headerConfig: {
                title: '',//标题栏内容
                left_type: 3,
                title_color: '#000',
                left_content: 'dark',
                header_color: '#fff'
            },

            openType: 0,//值见openTypeName
            openTypeName: ['', '旺票', '幸运值', '兑换券', '幸运券', '股份', '承兑汇票'],
            rUrl: ['', 'user/getConsumeTicketLog', 'user/getIncrementLog', 'user/getExchangeTicketLog', 'user/getVipCardLog', 'user/getStockLog', 'user/getAcceptanceBillLog'],

            list: [],

        };
    },
    onLoad(option) {
        // console.log(option);
        this.openType = option.openType || 1;
        this.value = option.value || 0;
        this.headerConfig.title = this.openTypeName[this.openType];

        setTimeout(() => {
            this.$comFun.openLoading();
            this.$refs.Zpaging.reload()
        }, 400);
    },
    onPageScroll(res) {
        this.pagescrollTop = res.scrollTop;
    },
    methods: {
        async getList(pageNo, pageSize) {
            let data = {
                pageNo: pageNo,
                pageSize: pageSize,
            };
            const res = await this.$request.get(this.rUrl[this.openType], data);
            this.$comFun.closeLoading();
            // console.log(res);
            if (res.code == 200) {
                this.$refs.Zpaging.complete(res.result.records);
            } else {
                this.$refs.Zpaging.complete(false);
            }
        }
    },
};
</script>

<style lang="scss" scoped>
@import "@/common/css/mine.scss";
</style>
